/**
 * @file SHA1.hpp
 *
 *  @date 2009-06-02
 *  @author hauleth
 */

#ifndef SHA1_HPP_
#define SHA1_HPP_

#include <Bust/Crypting/Hash.hpp>

namespace bust {

class SHA1 : public Hash {
	public:
		SHA1();
		virtual ~SHA1();

		std::string getHashFromString( std::string text );
		std::string getHashFromFile( std::string filename );
		const char* engineName();
	private:
		typedef unsigned char *POINTER;
		void SHA1_memcpy( POINTER, POINTER, unsigned int );
		void SHA1_memset( POINTER, int, unsigned int );
		typedef unsigned char BYTE;
		struct SHA1data {
				unsigned long int state[5]; /* Message digest */
				unsigned long int count[2]; /* 64-bit bit count */
				unsigned long int data[16]; /* SHS data buffer */
				int Endianness;
		};
		void init( SHA1data & );
		void update( SHA1data &, unsigned char*, int );
		void final( unsigned char*, SHA1data & );
		void transform( unsigned long int *, unsigned long int * );
		void encode( unsigned char*output, unsigned long int *input, unsigned int len );
		std::string convToString( unsigned char *bytes );
};

}

#endif /* SHA1_HPP_ */
